<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html lang="zh">
<head>
    <%@include file="/lyear/common/head.jsp" %>
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <%@include file="/lyear/common/aside.jsp" %>
        <!--End 左侧导航-->

        <!--头部信息-->
        <%@include file="/lyear/common/top.jsp" %>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div class="row">

                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header"><h4>水平排列的表单</h4></div>
                            <div class="card-body">

                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="oldPwd">原密码</label>
                                        <div class="col-md-7">
                                            <input class="form-control" type="password" id="oldPwd" name="oldPwd" placeholder="请输入旧密码">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="newPwd">新密码</label>
                                        <div class="col-md-7">
                                            <input class="form-control" type="password" id="newPwd" name="newPwd" placeholder="请输入新密码">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label" for="renewPwd">再次输入</label>
                                        <div class="col-md-7">
                                            <input class="form-control" type="password" id="renewPwd" placeholder="请再次输入新密码">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-md-9 col-md-offset-3">
                                            <button class="btn btn-primary" type="button" onclick="updatePwd()">确认修改</button>
                                            <button type="button" class="btn btn-default"
                                                    onclick="javascript:history.back(-1);return false;">返 回
                                            </button>
                                        </div>
                                    </div>
                                </form>

                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<script type="text/javascript" src="${pageContext.request.contextPath}/lyear/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lyear/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lyear/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lyear/js/main.min.js"></script>
<script type="text/javascript">
    function updatePwd(){


        let oldPwd = $("#oldPwd").val()
        let newPwd = $("#newPwd").val()
        console.log(oldPwd)
        console.log(newPwd)
        $.ajax({
            url: '/projshow/user/updatePwdById/'+oldPwd+"/"+newPwd, /*接口域名地址*/
            type: 'POST',
            contentType: false,
            processData: false,
            dataType: "json",
            success: function (res) {
                console.log(res);
                if (res.code == 200) {
                    alert("密码修改成功")


                    window.location.href="../../../index.jsp"
                }else {
                    alert("密码修改失败 傻狗 密码都记不住")
                }

            }
        })
    }



</script>
</body>
</html>